<template>
  <div>
    <el-dialog
      title="采纳历史"
      :visible.sync="dialogVisible"
      width="1000px"
      :lock-scroll="false"
    >
      <div style="min-height: 350px">
        <el-table :data="tableData" stripe style="width: 100%">
          <el-table-column prop="createTime" label="批注人">
            <template slot-scope="scope">
              {{ scope.row.sysUser | showUserInfo }}
            </template>
          </el-table-column>
          <el-table-column prop="size" label="状态">
            <template slot-scope="scope">
              <span v-show="scope.row.auditStatus == 1"> 建议 </span>
              <span class="color-success" v-show="scope.row.auditStatus == 2">
                采纳
              </span>
              <span class="color-waring" v-show="scope.row.auditStatus == 3">
                有用
              </span>
            </template>
          </el-table-column>
          <el-table-column prop="createTime" label="创建时间" width="180">
          </el-table-column>
          <el-table-column label="操作" width="120">
            <template slot-scope="{ row }">
              <el-button-group>
                <el-button
                  type="success"
                  size="mini"
                  @click="handleDetail(row)"
                >
                  预览
                </el-button>
              </el-button-group>
            </template>
          </el-table-column>
        </el-table>
        <Pagination
          v-show="parseInt(pageObj.count) > 0"
          :total="parseInt(pageObj.count)"
          @change="getList"
          :page.sync="listQuery.page"
          :limit.sync="listQuery.limit"
        />
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">关 闭</el-button>
      </span>
    </el-dialog>
    <ViewDetail />
  </div>
</template>
<script>
// import { sysKnowledgeStrategyLogQuery } from "@/api/home/sysKnowledgeStrategyLog";
import { sysKnowledgeStrategyQuery } from "@/api/admin/courseLibrary/sysKnowledgeStrategy.js";
import Bus from "@/utils/bus.js";
export default {
  data() {
    return {
      dialogVisible: false,
      listQuery: {
        page: 1,
        limit: 10,
        resId: "",
        resType: 1,
      },
      tableData: [],
      pageObj: {},
    };
  },
  mounted() {
    Bus.$on("showDialogSuggestHistory", (v) => {
      this.listQuery.resId = v.id;
      this.getList();
    });
  },
  beforeDestroy() {
    Bus.$off("showDialogSuggestHistory");
  },
  methods: {
    getList() {
      sysKnowledgeStrategyQuery(this.listQuery).then((res) => {
        this.tableData = res.data.data;
        this.pageObj = res.data;
        this.dialogVisible = true;
      });
    },
    //预览
    handleDetail(row) {
      Bus.$emit("showDialogViewDetail", row, "批注详情");
    },
  },
};
</script>
<style scoped>
.history-content {
  float: left;
  max-width: 440px;
  cursor: pointer;
}
</style>